package com.example.mrzhou.srtfoodapplication;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created by SRTfood on 2017/1/19.
 */

public class SettingLayout extends LinearLayout {

    //设置页面

    public SettingLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.setting,this);

        //将标题更改为：设置文本
        TextView TitleContent = (TextView)findViewById(R.id.title_content);
        TitleContent.setText("  设置");

        //检查更新功能
        Button CheckUpdata = (Button) findViewById(R.id.check_updata);
        CheckUpdata.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getContext(),"该版本为最SRTfood新版本",Toast.LENGTH_SHORT).show();
            }
        });

        //清空缓存功能
        Button WipeCache = (Button) findViewById(R.id.wipe_cache);
        WipeCache.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getContext(),"缓存已清空",Toast.LENGTH_SHORT).show();
            }
        });


        //关于我们
        Button AboutUs = (Button) findViewById(R.id.about_us);
        AboutUs.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getContext(),AppContentActivity.class);
                getContext().startActivity(intent);
            }
        });

        //退出登录功能
        Button ExitLogin = (Button) findViewById(R.id.exit_login);
        ExitLogin.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent("com.example.broadcastbestpractice.FORCE_OFFLINE");
                getContext().sendBroadcast(intent);
            }
        });




    }
}
